﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using System.Linq;

namespace KTX
{
    public partial class frmDangNhap : DevExpress.XtraEditors.XtraForm
    {
        public frmDangNhap()
        {
            InitializeComponent();
        }
        Data.QLKTXEntities db = new Data.QLKTXEntities();
       public Data.NguoiDung ShowMe()
        {
            this.ShowDialog();
            return ndung;
        }

        private void simpleButton2_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        Data.NguoiDung ndung;
        private void simpleButton1_Click(object sender, EventArgs e)
        {
            var ten= textEdit1.Text;
            var pas= textEdit2.Text;
            if (db.NguoiDung.Where(p=>p.TenDangNhap ==ten && p.MatKhau==pas).Any())
            {
                ndung = db.NguoiDung.Where(p => p.TenDangNhap == ten && p.MatKhau == pas).First();
                this.Close();
            }
            else
            {
                MessageBox.Show("Sai tên hoặc mật khẩu, vui lòng thử lại");
            }
        }
    }
}